package cn.achao.csr.system.service.impl;

import cn.achao.csr.api.SequenceApi;
import cn.achao.csr.api.model.dto.OperaAddDTO;
import cn.achao.csr.api.model.entity.SysOperationLog;
import cn.achao.csr.system.dao.SysOperationLogDao;
import cn.achao.csr.system.service.SysOperationLogService;

import cn.hutool.core.bean.BeanUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

/**
 * @author achao
 * @description 针对表【sys_operation_log(操作日志表)】的数据库操作Service实现
 * @createDate 2025-01-16 22:50:41
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SysOperationLogServiceImpl implements SysOperationLogService {

    private final SequenceApi sequenceApi;
    private final SysOperationLogDao operationLogDao;
    private final ThreadPoolTaskExecutor taskExecutor;

    @Override
    public boolean add(OperaAddDTO req) {
        SysOperationLog sysOperationLog = BeanUtil.copyProperties(req, SysOperationLog.class);
        try {
            taskExecutor.execute(() -> operationLogDao.save(sysOperationLog));
        } catch (Exception e) {
            return false;
        }
        return true;
    }

}




